package com.share.rules.fallback;

import com.share.common.core.domain.Result;
import com.share.rules.api.RemoteFeeRuleService;
import com.share.rules.domain.FeeRule;
import com.share.rules.domain.FeeRuleRequestForm;
import com.share.rules.domain.FeeRuleResponseVo;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

public class RemoteFeeRuleFallbackFactory implements FallbackFactory<RemoteFeeRuleService> {
    @Override
    public RemoteFeeRuleService create(Throwable throwable) {

        return new RemoteFeeRuleService() {
            @Override
            public Result<List<FeeRule>> getFeeRuleList(List<Long> feeRuleIdList) {
                return Result.fail("获取费用规则列表失败:" + throwable.getMessage());
            }

            @Override
            public Result<FeeRule> getFeeRule(Long id) {
                return Result.fail("获取费用规则信息失败:" + throwable.getMessage());
            }

            @Override
            public Result<FeeRuleResponseVo> calculateOrderFee(FeeRuleRequestForm feeRuleRequestForm) {
                return Result.fail("费用计算失败:" + throwable.getMessage());
            }
        };
    }
}
